// 发起一个post请求

import myAxios from "@/request";

/**
 * 用户注册
 *
 */
export const userRegister = async (params: any) => {
  return await myAxios.request({
    url: "/api/user/userRegister",
    method: "POST",
    data: params,
  });
};
/**
 * 发送验证码
 *
 */
export const sendCode = async (phone: any) => {
  return await myAxios.request({
    url: "/api/user/code",
    method: "POST",
    data: { phone },
  });
};

/**
 * 用户登录
 *
 */
export const userLogin = async (params: any) => {
  return await myAxios.request({
    url: "/api/user/userLogin",
    method: "POST",
    data: params,
  });
};

/**
 * 用户注销
 *
 */
export const logout = async () => {
  return await myAxios.request({
    url: "/api/user/logout",
    method: "POST",
  });
};

/**
 * 当前用户获取
 *
 */
export const getCurrentUser = async () => {
  return await myAxios.request({
    url: "/api/user/current",
    method: "GET",
  });
};

/**
 * 用户列表查询
 *
 */
export const searchUsers = async (username: any) => {
  return await myAxios.request({
    url: "/api/user/search",
    method: "GET",
    data: {
      username,
    },
  });
};

/**
 * 用户删除
 *
 */
export const deleteUsers = async (username: any) => {
  return await myAxios.request({
    url: "/api/user/delete",
    method: "POST",
    data: username,
    headers: {
      "Content-Type": " application/json",
    },
  });
};
